#include <Servo.h>
int b=1;
Servo myservo;
int pos = 0;
char var; 
int data;
void setup() {
  Serial.begin(9600); 
  myservo.attach(9);
}


void loop() {
  if (Serial.available() > 0) {
    b=(b+1)%3;    
    var = Serial.read();
    data=var-'0';
    Serial.println(data);
    if(b==0){
      myservo.write(90);
      delay(data*120);
      myservo.write(45);
      delay(1000);
    }        
  }
}
